package com.kkb.shopcenter.server.impl;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.kkb.shopcenter.api.RoleInfoService;
import com.kkb.shopcenter.common.pojo.RoleInfo;
import com.kkb.shopcenter.server.mappers.RoleInfoMapper;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import tk.mybatis.mapper.entity.Example;

import java.util.List;


@Service
public class RoleInfoServiceImpl implements RoleInfoService {

    @Autowired
    private RoleInfoMapper roleInfoMapper;

    @Override
    public List<RoleInfo> selectRolesByUserId(Long userId) {
        return roleInfoMapper.selectRoleByUserId(userId);
    }

    @Override
    public PageInfo<RoleInfo> getRoleList(byte type, Integer pageNo, Integer pageSize) {
        PageHelper.startPage(pageNo, pageSize);

        Example example = new Example(RoleInfo.class);
        example.createCriteria().andEqualTo("type",type);
        List<RoleInfo> roleInfos = roleInfoMapper.selectByExample(example);
        PageInfo<RoleInfo> pageInfo = new PageInfo<>(roleInfos);
        return pageInfo;
    }
}
